export interface sr_data{
	//id:sr_id,c_name,c_time,location,c_weeks,c_day:day,c_teacher,course_id,week,type,s_name,s_code
	sr_id:number,
	c_name:string,
	c_time:string,
	location:string,
	c_weeks:string,
	c_day:number,
	c_teacher:string,
	c_type:string,
	course_id:number,
	week:number,
	type:string,
	s_name:string,
	s_code:string,
	latitude:number,
    longitude:number,
    sign_start:number,
    sign_late_start:number,
    sign_end:number,
    radius:number,
}
export function decodeTimeId(time_id:string):{week:number,day:number,s_time:string,e_time:string}{
	const res = {week:0 as number,day:0 as number,s_time:'' as string,e_time:'' as string};
	let temp = time_id.split('-');
	res.week=Number(temp[0]);
	res.day=Number(temp[1]);
	res.s_time=temp[2];
	res.e_time=temp[3];
	return res;
}
const XLSX = require('xlsx');
export function exportExcel(data:string[][], filename:string) {
  const workbook = XLSX.utils.book_new();
  const sheet = XLSX.utils.aoa_to_sheet(data);

  XLSX.utils.book_append_sheet(workbook, sheet, 'Sheet1');

  const excelBuffer = XLSX.write(workbook, { bookType: 'xlsx', type: 'array' });
  const filePath = `${wx.env.USER_DATA_PATH}/${filename}.xlsx`;
	const fs = wx.getFileSystemManager();
	fs.saveFile({
		tempFilePath: filePath,
		filePath: filePath, //保存的时候必须跟上路径和文件名
		success: function (res) {
			console.log("保存成功")
			console.log(res)
		},
		fail: function (res) {
			console.log("保存失败")
			console.log(res)
		}
	})

  
}